package cn.just.controller;

import cn.just.entity.User;
import cn.just.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wujiaming
 */
@WebServlet(name = "RegServlet",value = "/RegServlet")
public class RegServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        String name = request.getParameter("name");
        String email = request.getParameter("email");
        String pwd = request.getParameter("pwd");
        User user = new User(null,name,pwd,email);
        UserService userService = new UserService();
        userService.save(user);
        response.sendRedirect("ShowLoginServlet");
    }


}
